package com.xjoyt.pay.master.po;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xjoyt.pay.constants.DateConstant;

/**
 * 代理商应付
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_distributor_checkout")
public class DistributorCheckout {

	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid2")
	@Column(name = "distributor_checkout_id", length = 36)
	public String id;

	/**
	 * 代理商
	 */
	@ManyToOne(targetEntity = Distributor.class, cascade = {})
	@JoinColumn(name = "distributor_id", foreignKey = @ForeignKey(name = "none"))
	public Distributor distributor;

	/**
	 * 录入日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date addedDate;

	/**
	 * 付款日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "`date`")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date date;

	/**
	 * 金额(分)
	 */
	@Column(name = "money")
	public Long money;

	/**
	 * 状态：生效、失效
	 */
	@Column(name = "is_enabled")
	@org.hibernate.annotations.Type(type = "yes_no")
	public Boolean enabled;

	/**
	 * 明细
	 */
	@OneToMany(targetEntity = DistributorCheckoutDetail.class, cascade = { CascadeType.REMOVE })
	@JoinColumn(name = "distributor_checkout_id", foreignKey = @ForeignKey(name = "none"))
	public List<DistributorCheckoutDetail> details;
}
